package com.bauer.java.hadoop.mrduce.demo;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reporter;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @program: java
 * @description: 计数mapper
 * @author: bauer weo
 * @create: 2019-07-28 16:49
 */
public class WordCountMapper extends Mapper<LongWritable, Text, Text, LongWritable> {

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String[] strA = value.toString().split(" ");
        for (String key1 : strA) {
            context.write(new Text(key1), new LongWritable(1));
        }
    }

}
